import React from 'react';
import BaseAction from './BaseAction';
import ResponseConstants from '../../common/ResponseConstants';

export default class CommonSendRequestAction extends BaseAction {
  constructor(props) {
    super(props);
  }

  finish(data, result, response) {
    let detail = "服务器错误";
    if(data && data.detail != undefined) {
      detail = data.detail;
    }
    if(result) {
      this._dealFinishSucess(data, response);
    }
    else {
      if(response.status === ResponseConstants.status_unauthorized) {
        this._dealUnauthorized();
      }
      else {
        this._dealFinishFailed(data, response, detail);
      }
    }
  }

  _dealFinishFailed(data, response, detail) {
    this.caller.setState({
      viewStatus:response.status,
      statusText:detail + " " + response.status,
    })
  }

  _dealFinishSucess(data, response) {

  }
}
